import { Type } from 'class-transformer';
import {
  IsNotEmpty,
  IsOptional,
  IsInt,
  IsJSON,
  IsDate,
  IsObject,
} from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { EventToPlayer } from 'src/modules/event-to-player/entities/event-to-player.entity';
import { MatchInfo } from 'src/modules/match/entities/match.entity';

export class CreateGameDto {
  @ApiPropertyOptional({ description: '游戏 ID', type: Number, example: 1 })
  @IsOptional()
  @IsInt()
  id?: number;

 
  // @ApiPropertyOptional({ description: '主场玩家', type: () => EventToPlayer })
  // @IsOptional()
  // @IsObject()
  // homePlayer?: EventToPlayer;

  // @ApiPropertyOptional({ description: '客场玩家', type: () => EventToPlayer })
  // @IsOptional()
  // @IsObject()
  // awayPlayer?: EventToPlayer;

  // @ApiPropertyOptional({ description: '获胜者', type: () => EventToPlayer })
  // @IsOptional()
  // @IsObject()
  // winner?: EventToPlayer;

  @ApiPropertyOptional({ description: '主场玩家 ID', type: Number, example: 1 })
  @IsInt()
  homePlayerId: number;

  @ApiPropertyOptional({ description: '客场玩家 ID', type: Number, example: 2 })
  @IsInt()
  awayPlayerId: number;

  @ApiPropertyOptional({ description: '获胜者 ID', type: Number, example: 1 })
  @IsOptional()
  @IsInt()
  winnerId?: number;

  @ApiPropertyOptional({ description: '比赛进程', example: {} })
  @IsOptional()
  progress?: any;

  @ApiPropertyOptional({ description: '最新的比赛进程', example: {} })
  @IsOptional()
  lastProgress?: any;

  @ApiPropertyOptional({
    description: '开始时间',
    type: Date,
    example: new Date(),
  })
  @Type(() => Date)
  @IsOptional()
  @IsDate()
  startTime?: Date;

  @ApiPropertyOptional({
    description: '结束时间',
    type: Date,
    example: new Date(),
  })
  @Type(() => Date)
  @IsOptional()
  @IsDate()
  endTime?: Date;

  @ApiPropertyOptional({ description: '状态', type: Number, example: 1 })
  @IsOptional()
  @IsInt()
  status?: number;

  @ApiPropertyOptional({ description: '比赛信息', type: () => MatchInfo })
  @IsOptional()
  @IsObject()
  matchInfo?: MatchInfo;

  @ApiPropertyOptional({ description: '比赛 ID', type: Number, example: 1 })
  @IsOptional()
  @IsInt()
  matchId?: number;

  @ApiProperty({ description: '游戏索引', type: Number, example: 1 })
  @IsNotEmpty()
  @IsInt()
  gameIndex?: number;

  @ApiPropertyOptional({
    description: '主场玩家回合数',
    type: Number,
    example: 10,
  })
  @IsOptional()
  @IsInt()
  homePlayerRally?: number;

  @ApiPropertyOptional({
    description: '客场玩家回合数',
    type: Number,
    example: 8,
  })
  @IsOptional()
  @IsInt()
  awayPlayerRally?: number;

  @ApiPropertyOptional({ description: '回合规则 ID', type: Number, example: 1 })
  @IsOptional()
  @IsInt()
  rallyRuleId?: number;

  createBy?: number;

  createTime?: Date;

  updateBy: number;

  updateTime?: Date;
}
